﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	xmlns:nyt="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit" xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
	xmlns:nytvc="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit"
	xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
	x:Class="DemoNYTimes.BillsCosponsoredByMember"
	d:DesignWidth="640" d:DesignHeight="480">

	<UserControl.Resources>
		<nytvc:DateTimeConverter x:Key="DateTimeConverter"/>
		<nytvc:CongressMemberConverter x:Key="CongressMemberConverter"/>
		<nytvc:PartyColorConverter x:Key="PartyColorConverter"/>
		<nyt:MembersOfCongress Chamber="Senate" CongressNumber="111" x:Key="MembersOfCongressDataSource" d:IsDataSource="True"/>
		<nyt:BillsCosponsoredByMember x:Key="BillsCosponsoredByMemberDataSource" d:IsDataSource="True"/>
		<DataTemplate x:Key="CongressMemberTemplate">
			<StackPanel Orientation="Horizontal">
				<TextBlock Text="{Binding Name}" Foreground="{Binding Party, Converter={StaticResource PartyColorConverter}, Mode=OneWay}"/>
				<TextBlock Text=" (" TextWrapping="Wrap"/>
				<TextBlock Text="{Binding Party}"/>
				<TextBlock Text="-" TextWrapping="Wrap"/>
				<TextBlock Text="{Binding State}"/>
				<TextBlock Text=")" TextWrapping="Wrap"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate x:Key="BillTemplate">
			<Border Background="#FFEEEEEE" BorderBrush="#FF242424" BorderThickness="0,0,1,1" CornerRadius="5">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
					</Grid.RowDefinitions>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="10"/>
						<ColumnDefinition Width="Auto"/>
						<ColumnDefinition/>
					</Grid.ColumnDefinitions>
					<Grid Grid.ColumnSpan="3" d:LayoutOverrides="Width, Height">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto"/>
							<RowDefinition/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition/>
						</Grid.ColumnDefinitions>
						<TextBlock x:Name="Id" Text="{Binding Id}" FontFamily="Times New Roman" FontSize="32" FontWeight="Bold" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="2,2,2,0"/>
						<TextBlock x:Name="Title" Text="{Binding Title}" TextWrapping="Wrap" d:LayoutOverrides="Width" Grid.Column="1" Grid.RowSpan="2" Margin="2" FontSize="13.333"/>
						<StackPanel Orientation="Horizontal" Margin="2,0,2,2" VerticalAlignment="Top" Grid.Row="1">
							<TextBlock x:Name="Cosponsors" Text="{Binding Cosponsors}" FontSize="13.333" Foreground="#FF1B920A" VerticalAlignment="Top"/>
							<TextBlock Text=" Cosponsors" TextWrapping="Wrap" FontSize="13.333" Foreground="#FF1B920A" VerticalAlignment="Top"/>
						</StackPanel>
					</Grid>
					<dataInput:Label HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Top" Content="Introduced: " Grid.Row="1" Grid.Column="1"/>
					<TextBlock x:Name="Introduced" Text="{Binding Introduced, Converter={StaticResource DateTimeConverter}, ConverterParameter=d, Mode=OneWay}" Margin="0" VerticalAlignment="Bottom" Grid.Column="2" Grid.Row="1"/>
					<dataInput:Label HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Top" Content="Cosponsored: " Grid.Row="2" Grid.Column="1"/>
					<dataInput:Label Margin="5,0,0,0.203" Content="Last Major Action: " Grid.Row="3" Grid.Column="1"/>
					<TextBlock x:Name="LastMajorActionDate" Text="{Binding LatestMajorActionDate, Converter={StaticResource DateTimeConverter}, ConverterParameter=d, Mode=OneWay}" Margin="0,0,0,0.203" VerticalAlignment="Bottom" Grid.Column="2" Grid.Row="3"/>
					<TextBlock x:Name="CosponsoredDate" Grid.Column="2" Grid.Row="2" Text="{Binding CosponsoredDate, Converter={StaticResource DateTimeConverter}, ConverterParameter=d, Mode=OneWay}" TextWrapping="Wrap" d:LayoutOverrides="Width"/>
					<TextBlock x:Name="LastMajorAction" Text="{Binding LatestMajorAction}" VerticalAlignment="Bottom" Grid.ColumnSpan="2" Grid.Row="4" TextWrapping="Wrap" Margin="5,0,0,0" FontStyle="Italic" Grid.Column="1"/>
				</Grid>
			</Border>
		</DataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource MembersOfCongressDataSource}}" Background="White">
		<ListBox x:Name="Members" HorizontalAlignment="Left" Margin="8,64,0,28" Width="229" ItemTemplate="{StaticResource CongressMemberTemplate}" ItemsSource="{Binding Members}" SelectedItem="{Binding MemberId, Converter={StaticResource CongressMemberConverter}, Mode=TwoWay, Source={StaticResource BillsCosponsoredByMemberDataSource}, UpdateSourceTrigger=Default}"/>
		<ListBox x:Name="Bills" DataContext="{Binding Source={StaticResource BillsCosponsoredByMemberDataSource}}" Margin="241,8,8,28" ItemTemplate="{StaticResource BillTemplate}" ItemsSource="{Binding Bills}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalContentAlignment="Stretch"/>
		<ListBox x:Name="House" Height="52" HorizontalAlignment="Left" Margin="8,8,0,0" VerticalAlignment="Top" Width="54" SelectedItem="{Binding Chamber, Mode=TwoWay, Source={StaticResource MembersOfCongressDataSource}}">
			<nyt:Chamber>House</nyt:Chamber>
			<nyt:Chamber>Senate</nyt:Chamber>
		</ListBox>
		<dataInput:Label HorizontalAlignment="Left" Margin="66,8,0,0" VerticalAlignment="Top" Content="Congress:" Height="22"/>
		<HyperlinkButton HorizontalAlignment="Left" Margin="8,0,0,8" VerticalAlignment="Bottom" Content="Bills Cosponsored by a Member API" NavigateUri="http://developer.nytimes.com/docs/congress_api#h3-cosponsor-bills" TargetName="_blank" ToolTipService.ToolTip="New York Times Developer Network"/>
		<TextBlock DataContext="{Binding Source={StaticResource BillsCosponsoredByMemberDataSource}}" HorizontalAlignment="Right" Margin="0,0,8,8" VerticalAlignment="Bottom" Text="{Binding Copyright, Mode=OneWay}" TextWrapping="Wrap"/>
		<inputToolkit:NumericUpDown x:Name="CongressNumber" HorizontalAlignment="Left" Margin="126,8,0,0" VerticalAlignment="Top" d:LayoutOverrides="Height" Width="44" Minimum="80" Maximum="111" Value="{Binding CongressNumber, Mode=TwoWay, UpdateSourceTrigger=Default}"/>
	</Grid>
</UserControl>